package view;

import java.util.List;

import net.sf.json.JSONArray;
import net.sf.json.JsonConfig;

import com.opensymphony.xwork2.ActionSupport;

import data.VendorInfoBean;

public class VendorAction extends ActionSupport {
	private JSONArray vendors;
	
	public JSONArray getVendors() {
		return vendors;
	}

	public void setVendors(JSONArray vendors) {
		this.vendors = vendors;
	}

	public String execute(){
		if (vendors == null){
			List<VendorInfoBean> vl = VendorDeviceBean.fetchVendorList();
			JsonConfig jsonConfig = new JsonConfig();
			String[] excludsField = {"callback"}; 
			jsonConfig.setExcludes(excludsField);
			vendors = JSONArray.fromObject(vl, jsonConfig);
		}
		return SUCCESS;
	}
}
